package cn.wolfcode.controller;

import cn.wolfcode.domain.Dept;
import cn.wolfcode.domain.Result;
import cn.wolfcode.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/depts")
    public Result list(){
        List<Dept> list = deptService.list();
       log.info("查询所有部门信息");
       return Result.success(list);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id){
        log.info("删除id:{}的部门信息",id);
        deptService.delete(id);
        return Result.success();
    }

}
